define(["jquery", "easy-admin"], function ($, ea) {

    var status =$('#status').val();
    var init = {
        table_elem: '#currentTable',
        table_render_id: 'currentTableRenderId',
        index_url: 'mall.order/index?status='+status,
        edit_url: 'mall.order/edit',
        refund_url:'mall.order/torefund',
        info_url: 'mall.order/info',
        delete_url: 'mall.order/delete',
        export_url: 'mall.order/export?status='+status,
        modify_url: 'mall.order/modify',
    };
    var Controller = {
        index: function () {
            ea.table.render({
                init: init,
                defaultToolbar: ['filter'],
                height:'full-50',
                done: function(res, curr, count){
                    //如果是异步请求数据方式，res即为你接口返回的信息。
                    //如果是直接赋值的方式，res即为：{data: [], count: 99} data为当前页数据、count为数据总长度
                    console.log(res);
                    $("#totalday").html(res.alltotal);
                    $("#totallirun").html(res.lirun);
                },
            cols: [[
                    {type: 'checkbox'},
                    {field: 'id',width: 80, title: 'id',search: false},
                    {field: 'orderno', width:230, title: '订单号'},
                    {field: 'manager_id',width:120, title: '所属商家','search':'select',selectList: managerList},
                    {field: 'goods_title',width:200, title: '商品名称'},
                    {field: 'specs_value_ids',width: 100, title: '规格',search: false},
                    {field: 'realname', width: 200,title: '买家昵称'},
                    {field: 'mobile', width: 150, title: '联系电话'},
                    {field: 'orderprice', width: 100, title: '订单金额', search:false},
                    {field: 'payprice', width: 150, title: '应付金额', search:false},
                    {field: 'cost_price', width: 100, title: '成本价', search:false},
                    {field: 'goods_num', width: 100, title: '数量', search:false},
                    {field: 'bonus_price', width: 100, title: '红包抵扣', search:false},
                    {field: 'discount', width: 100, title: '优惠金额', search:false},

                    {field: 'pay_type', width: 100, selectList: {"1":"微信支付","2":"支付宝支付","3":"合众支付"}, title: '支付方式'},
                    {field: 'status', width: 100, search: 'select', selectList: {"0":"待付款","1":"待核销","2":"已核销","3":"已退款","4":"订单取消"}, title: '状态'},
                    {field: 'hxuser', width: 150, title:'核销人',search: false,},
                    {field: 'create_time', width: 160, title: '下单时间',search: 'range'},
                    {field: 'pay_time', width: 160, title: '付款时间',search: false},
                    {field: 'canceltime', width: 160, title: '失效时间',search: false},
                    {field: 'refund_time', width: 160, title: '退款时间',search: false},
                    {field: 'hx_time',width: 160,title:'完成时间',search: false},
                    {
                        width: 250,
                        title: '操作',
                        templet: ea.table.tool,
                        operat: [
                            [
                            {
                                text: '确认退款',
                                url: init.refund_url,
                                method: 'confirm',
                                auth: 'torefund',
                                class: 'layui-btn layui-btn-xs layui-btn-normal',
                                extend: 'data-full="true"',
                                show:[
                                    {"name":"status","value":"1"}
                                 ]
                            },{
                                text: '订单详情',
                                url: init.info_url,
                                method: 'open',
                                auth: 'info',
                                class: 'layui-btn layui-btn-xs layui-btn-normal',
                                extend: 'data-full="true"',
                            }],
                        ]
                    },
                ]],
            });
            ea.listen();
        },
        edit: function () {
            ea.listen();
        },
        info: function () {
            ea.listen();
        },
    };
    return Controller;
});